<template>
	<div>
		<div class="header">
			<span class="logo"><img src="../img/logo@3x.png" @click="zhuye()"/></span>
			<div class="seach-box" @click="seachStuta==true&&seachbtn()">
				<i class="seachimg"><img src="../img/icon_search@3x.png"/></i>
				<span v-show="seachshow">搜索商品</span>
				<form action="javascript:;" v-show="seachinput">
					<input type="search" name="" id="seach" value="" v-model="seachvalue" placeholder="搜索商品" @keyup.enter="seachsend" autofocus="autofocus" />
				</form>

			</div>
			<router-link :to="nt_user!=0?'/informationlist':'/login'" class="xiaoxi" v-show="!seachrmshow"><img src="../img/icon_news@3x.png" /><span id="xmessage"></span></router-link>
			<span class="qxsousuo dasousuo" v-show="seachrmshow" @click="seachremove()">取消</span>
		</div>
		<div class="bannert2" style="width: 100%;height: auto;">
			<img src="../img/smmg_header.jpg" style="width: 100%;height: 100%;" />
		</div>
		<div class="zy_media">
		    <video autoplay="autoplay" loop="loop">
		        <source src="http://liangzhong.oss-cn-hangzhou.aliyuncs.com/video/smmg.mp4" type="video/mp4">
		      	您的浏览器不支持HTML5视频
		   	</video>
		</div>
		<!--<div @click="tzsp()" class="ddddd" style="width: 100%;height: 180px;background-color: rgba(9,9,9,0);"></div>-->
		<div style="width: 100%;height: auto;margin-top: 0px;">
			<a href="http://www.ntyouxuan.com/newnt/#/shopXQ/1239"><img src="../img/smmg_footer1.jpg" style="width: 100%;height: 100%;" /></a>
			<img src="../img/smmg_footer.jpg" style="width: 100%;height: 100%;" />
			<img @click="ffdb1()" src="../img/footer-btn.jpg" style="width: 100%;height: 100%;" />
		</div>	
	</div>

</template>

<script>
	import ckp from '../css/zy.media.min.css'
	import ckpjs from '../js/zy.media.min.js'
	import wx from 'weixin-js-sdk'
	
	var furl = "http://www.ntyouxuan.com/";
	export default{
		name:'video',
		data () {
			return {
				ind:0,
				seachshow:true,
				seachStuta: true,
				seachinput: false,
				arealist:[],
				seachvalue:'',
				seachrmshow:false,
				wxdata:{
					'appid':'',
					'timestamp':'',
					'wxnonceStr':'',
					'wxShal':'',
					'title':'',
					'title_desc':'',
					'link':'',
					'img_url':'', 
				},
				aurl:''
			}
				
		},
		methods:{
			isWeiXin() {
		      let ua = window.navigator.userAgent.toLowerCase();
		      //mozilla/5.0 (iphone; cpu iphone os 9_1 like mac os x) applewebkit/601.1.46 (khtml, like gecko)version/9.0 mobile/13b143 safari/601.1
		      if (ua.match(/MicroMessenger/i) == 'micromessenger') {
		      return true;
		      } else {
		      return false;
		      }
		    },
		    seachbtn: function () {
		      var self = this
		      var b = 0
		      for (var i = 151; i > 20; i--) {
		        (function (i) {
		          var a = i
		          setTimeout(function () {
		            $('.seachimg img').css('margin-left', a / 100 + 'rem')
		            if (i <= 21) {
		              self.seachshow = false
		              self.seachinput = true
		              self.seachrmshow = true
		              setTimeout(function () {
		                document.getElementById('seach').focus()
		              }, 100)
		              self.seachStuta = false
		            }
		          }, 1 * b)
		          b++
		        })(i)
		      }
		    },
		    
		    seachremove: function () {
			// 当点击搜索时的动画
		      this.seachinput = false
		      var self = this
		      self.seachrmshow = false
		      setTimeout(function () {
		        self.seachshow = true
		        $('.seachimg img').css('margin-left', 151 / 100 + 'rem')
		        self.seachStuta = true;
		      }, 100)
		    },
		    seachsend:function(){
		    	var self=this;
		    	localStorage.setItem("nt_keyword",self.seachvalue);
		    	this.$router.push({path:'/seachall'});
		    },
			zhuye: function() {
				window.location.href = 'http://www.ntyouxuan.com/newnt/#/';
			},
			seachsend:function(){
		    	var self=this;
		    	localStorage.setItem("nt_keyword",self.seachvalue);
		    	this.$router.push({path:'/seachall'});
		    },
			seachsendtow:function(data){
		  		localStorage.setItem("nt_keyword",data);
		  		this.seachremove();
		    	var self=this;
		    	self.seachrmshow=false;
				  setTimeout(function () {
				  	self.$router.push({path:'/seachall'});
				  }, 150);
		  	},
			ffdb1:function(){
				$('html,body').animate({scrollTop:0},'slow');
			},
//			tzsp:function(){
//				window.location.href = 'http://www.ntyouxuan.com/newnt/#/shopXQ/1239';
//			}
		},
		created:function(){
		},
		mounted:function(){
		    zymedia('video',{autoplay: true});
		    var self=this;
			window.addEventListener("scroll",this.menu);
		    this.adurl=location.href;
			$.ajax({
				type:"post",
				url:furl+"index.php?app=ajax_third_login&act=wxjssdk",
				data:{'aurl':self.adurl},
				dataType:'json',
				success:function(res){
					self.wxdata.img_url="http://liangzhong.oss-cn-hangzhou.aliyuncs.com/activity/laba/smmg/smmg.jpg";
	         		self.wxdata.link="http://www.ntyouxuan.com/newnt/#/smmg";
	        		self.wxdata.title='【农淘优选】三门甜瓜';
	        		self.wxdata.title_desc="吹着海风慢慢长大，独特的黏质淡涂地土壤，更营养口感更脆甜。";
	        		
					if(res.done){
						self.wxdata.appid=res.retval.appid;
						self.wxdata.timestamp=res.retval.timestamp;
						self.wxdata.wxShal=res.retval.wxShal;
						self.wxdata.wxnonceStr=res.retval.wxnonceStr;
						if(self.isWeiXin()){
							self.wxConfig(wx,self.wxdata);
						}
						
					}
				}
			});
		 	$.ajax({
				type: "get",
				url: furl + "index.php?app=ajax&act=new_message",
				dataType: 'json',
				success: function(res) {
					self.xiaoxitx=res.retval.new_message;
					if(self.xiaoxitx == 0){
						$("#xmessage").css("display","none")
					}
					console.log(self.xiaoxitx)
				}
			});
		}
			
			
		
	}
</script>

<style>
	.zy_media{
		width: 95%;
		background-color: rgba(9,9,9,0);
		border: 3px solid #FF9501;
		border-radius: 2%;
		margin: 0 auto;
	}
	.bannert2{
		margin-top: 0.9rem;
	}
	.ddddd{
		overflow: hidden;
		z-index: 999;
		position: relative;
		top: 0.5rem;
		
	}
</style>